{include file="header.html"}
<body class="gr">

<div class="navBar">
	<a class="left" href="wap.php?app=member&act=coffee_order"><i class="return"></i></a>
	<div class="titleView">休闲馆订单详情</div>
</div>

<div class="member-order-detail member-coffee-order-detail main-top">
	<ul class="groupView">
		<li>
			<div class="top">{$data->status}</div>
			<div class="address">
				<div>
					<span>送去: {$data->desk}号 座位</span>
					<font>小票留言: {if $data->memo!=''}{$data->memo}{else}-{/if}</font>
				</div>
			</div>
		</li>
		
		<li>
			<ul>
				{foreach from=$data->coffees name=g item=g}
				<li class="ge-bottom ge-light">
					<div class="gview" price="{$g->price}" quantity="{$g->quantity}">
						<a href="wap.php?app=coffee&act=detail&coffee_id={$g->coffee_id}" class="pic" style="background-image:url({$g->coffee_pic});"></a>
						<a href="wap.php?app=coffee&act=detail&coffee_id={$g->coffee_id}" class="name right"><span class="price">￥{number_format($g->price,2)}</span>{$g->coffee_name}</a>
						<div class="spec"><span>×{$g->quantity}</span><div></div></div>
						{if $data->status>=2}
						{if $g->comment_time==0}
						<div class="comment"><a href="wap.php?tpl=member.coffee_order_comment&order_id={$data->id}&coffee_id={$g->coffee_id}&coffee_name={$g->coffee_name}&coffee_pic={$g->coffee_pic}"><span>评价</span></a></div>
						{else}
						<div class="comment"><font>已评价</font></div>
						{/if}
						{/if}
					</div>
				</li>
				{/foreach}
			</ul>
			<div class="view coffee">
				<div class="total"><strong>￥{number_format($data->total_price,2)}</strong><span>实付款</span></div>
			</div>
		</li>
		
		<li>
			<div class="info">
				<div>订单状态: <span class="status">{$data->status}</span></div>
				<div>订单编号: {$data->order_sn}</div>
				<div>创建时间: {$data->add_time_str}</div>
				{if $data->pay_time>0}<div>付款时间: {$data->pay_time_str}</div>{/if}
				{if $data->shipping_time>0}<div>派送时间: {$data->shipping_time_str}</div>{/if}
			</div>
		</li>
	</ul>
	
	{if $data->status==0 || $data->status>=2}
	<div class="bottomView" mid="{$data->id}">
		<div>
			{if $data->status==0}
			<a class="pay" href="javascript:void(0)" pay_method="{$data->pay_method}"><span>马上支付</span></a>
			<a class="cancel" href="javascript:void(0)"><span>取消订单</span></a>
			<form class="pay_form" action="wap.php?app=member&act=coffee_order_pay" method="post">
			<input type="hidden" name="re_order_sn" value="" />
			<input type="hidden" name="order_sn" value="{$data->order_sn}" />
			<input type="hidden" name="price" value="{$data->total_price}" />
			<input type="hidden" name="body" value="商富商城-咖啡订单" />
			</form>
			<form class="cancel_form" action="api.php?app=member&act=coffee_order_cancel" method="post">
			<input type="hidden" name="gourl" value="wap.php?app=member&act=coffee_order_detail&id={$data->id}" />
			<input type="hidden" name="id" value="{$data->id}" />
			</form>
			{/if}
			{if $data->status>=2}
			<a class="again ok" href="javascript:void(0)"><span>再次下单</span></a>
			<form class="again_form" action="api.php?app=coffee_cart&act=add_cart" method="post">
			<textarea style="display:none;">{json_encode($data->coffees)}</textarea>
			<input type="hidden" name="gourl" value="wap.php?app=coffee_cart&act=index" />
			<input type="hidden" name="coffees" class="coffees" value="" />
			</form>
			{/if}
		</div>
	</div>
	{/if}
</div>

{include file="footer.html"}
<script>
function statusName(status){
	var name = '';
	switch(status*1){
		case -3:name = '已退货';break;
		case -2:name = '已退款';break;
		case -1:name = '取消';break;
		case 0:name = '待付款';break;
		case 1:name = '待派送';break;
		case 2:
		case 3:
		case 4:name = '已派送';break;
	}
	return name;
}
function setInfo(){
	$('.gview .pic').loadbackground();
	$('.view .total strong, .price').priceFont('bigPrice');
}
$(function(){
	setInfo();
	$('.info .status, .top').html(function(i, html){ return statusName(html) });
	$('a.pay').click(function(){
		if($.browser.wechat && $(this).attr('pay_method')!='wxpay' && $(this).attr('pay_method')!='wxpay_h5'){
			alert('在微信上只能使用微信支付\n该订单下单时使用了支付宝方式');
			return false;
		}
		$('.pay_form').submit();
	});
	$('a.cancel').click(function(){
		if(!confirm('真的要取消吗？'))return false;
		$('.cancel_form').submit();
	});
	$('a.again').click(function(){
		$.overload(null);
		var count = 0, data = $('.again_form textarea').val().formatJSON(), arr = [];
		if(!$.isArray(data))return false;
		for(var i=0; i<data.length; i++){
			var coffees = { coffee_id:data[i].coffee_id, quantity:1 };
			arr.push(coffees);
			count++;
			if(count == data.length){
				var val = { coffees:arr };
				$('.coffees').val($.jsonString(val));
				$('.again_form').submit();
			}
		}
	});
});
</script>
